home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_222 / plplot / examples / example04.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  990b  |  39 lines

  1. /* Illustration of logarithmic axes, and redefinition of window */
  2.  
  3. #include <math.h>
  4.  
  5. main()
  6. {
  7.       int i;
  8.       float freql[101],ampl[101],phase[101];
  9.       float f0, freq;
  10.  
  11.       plstar(1,1);
  12.       pladv(0);
  13.       plfont(2);
  14.  
  15.       f0 = 1000.0;
  16.       for (i=0; i<=100; i++) {
  17.         freql[i]=1.0+i/20.0;
  18.         freq= pow(10.0,freql[i]);
  19.         ampl[i]=20.0*log10(1.0/sqrt(1.0+pow((freq/f0),2.)));
  20.         phase[i]=-(180.0/3.141592654)*atan(freq/f0);
  21.       }
  22.  
  23.       plvpor(0.15,0.85,0.1,0.9);
  24.       plwind(1.0,6.0,-80.0,0.0);
  25.       plbox("bclnst",0.0,0,"bnstv",0.0,0);
  26.       plline(101,freql,ampl);
  27.       plptex(5.0,-30.0,1.0,-20.0,0.5,"-20 dB/decade");
  28.       plwind(1.0,6.0,-100.0,0.0);
  29.       plbox(" ",0.0,0,"cmstv",30.0,3);
  30.       plline(101,freql,phase);
  31.  
  32.       plmtex("b",3.2,0.5,0.5,"Frequency");
  33.       plmtex("t",2.0,0.5,0.5,"Single Pole Low-Pass Filter");
  34.       plmtex("l",5.0,0.5,0.5,"Amplitude (dB)");
  35.       plmtex("r",5.0,0.5,0.5,"Phase shift (degrees)");
  36.  
  37.       plend();
  38. }
  39.